package com.travel.photos.ui.find.searchpurpose;

import android.widget.Toast;

import com.travel.R;
import com.travel.photos.base.BaseFragment;
import com.travel.photos.ui.find.PhotoSearchActivity;
import com.travel.photos.ui.find.search.SearchPurPoseAdapter;
import com.travel.photos.weixin.PullUpLoadMoreListView;

import butterknife.Bind;

/**
 * Created by meidou on 2016/10/18.
 * 发现的fragment
 */
public class PhotoSearchPurPoseFragment extends BaseFragment implements PhotoSearchPurPoseContract.View{
    @Bind(R.id.photo_find_serach_list)
    PullUpLoadMoreListView listview;
    private PhotoSearchPurPosePresenter mPresenter;
    private  String i;

    public PhotoSearchPurPoseFragment(String i) {
        this.i = i;
    }

    @Override
    public void getDetail(SearchPurPoseAdapter adapter) {
        listview.setAdapter(adapter);
    }

    @Override
    protected void initData() {
        //String searchcontent = new PhotoSearchActivity().getSearchcontent();
        if(i==null){
            Toast.makeText(getContext(),"请输入内容",Toast.LENGTH_SHORT).show();
        }else {
            mPresenter = new PhotoSearchPurPosePresenter(this,i);
            mPresenter.getDetail(getActivity());
        }
    }

    @Override
    protected void initView() {
        //上拉加载
        listview.setOnLoadMoreListener(new PullUpLoadMoreListView.OnLoadMoreListener() {
            @Override
            public void loadMore() {
                mPresenter.UpRefresh(getContext());
            }
        });
    }
    @Override
    protected int getLayoutId() {
        return R.layout.photo_search_vp;
    }
}
